package com.poker;

import java.util.List;

/**
 * 四条的大小比较
 */
public class SiTiaoComparePokers implements PokerCompare {


    /**
     * 四条的比较规则为：
     * 四种情况：
     * aaaab aaaab
     * aaaab baaaa
     * baaaa aaaab
     * baaaa baaaa
     */
    @Override
    public Integer comparePokers(List<Integer> gamblerOne, List<Integer> gamblerTwo) {
        int oneType = gamblerOne.get(0).compareTo(gamblerOne.get(1));
        int twoType = gamblerTwo.get(0).compareTo(gamblerTwo.get(1));
        if (oneType == 0 && twoType == 0) { //aaaab aaaab情况
            int i = gamblerOne.get(0).compareTo(gamblerTwo.get(0));
            if (i != 0) {
                return i;
            } else {
                return gamblerOne.get(4).compareTo(gamblerTwo.get(4));
            }
        } else if (oneType == 0 && twoType != 0) { //aaaab baaaa情况
            int i = gamblerOne.get(0).compareTo(gamblerTwo.get(4));
            if (i != 0) {
                return i;
            } else {
                return gamblerOne.get(4).compareTo(gamblerTwo.get(0));
            }
        } else if (oneType != 0 && twoType == 0) { //baaaa aaaab情况
            int i = gamblerOne.get(4).compareTo(gamblerTwo.get(0));
            if (i != 0) {
                return i;
            } else {
                return gamblerOne.get(0).compareTo(gamblerTwo.get(4));
            }
        } else {
            int i = gamblerOne.get(4).compareTo(gamblerTwo.get(4)); //baaaa baaaa情况
            if (i != 0) {
                return i;
            } else {
                return gamblerOne.get(0).compareTo(gamblerTwo.get(0));
            }
        }

    }
}
